home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / qblocks.zip / QBLOCKS.BAS next >
BASIC Source File  |  1992-02-21  |  54KB  |  1,179 lines

  1. '                                QBLOCKS.BAS
  2. '
  3. ' Press Page Down for information on running and modifying QBlocks.
  4. '
  5. ' To run this game, press Shift+F5.
  6. '
  7. ' To exit this program, press ALT, F, X.
  8. '
  9. ' To get help on a BASIC keyword, move the cursor to the keyword and press
  10. ' F1 or click the right mouse button.
  11. '
  12. '                             Suggested Changes
  13. '                             -----------------
  14. '
  15. ' There are many ways that you can modify this BASIC game.  The CONST
  16. ' statements below these comments and the DATA statements at the end
  17. ' of this screen can be modified to change the following:
  18. '
  19. '    Block shapes
  20. '    Block rotation
  21. '    Number of different block shapes
  22. '    Score needed to advance to next level
  23. '    Width of the game well
  24. '    Height of the game well
  25. '    Songs played during game
  26. '
  27. ' On the right side of each CONST statement, there is a comment that tells
  28. ' you what it does and how big or small you can set the value.  Above the
  29. ' DATA statements, there are comments that tell you the format of the
  30. ' information stored there.
  31. '
  32. ' On your own, you can also add exciting sound and visual effects or make any
  33. ' other changes that your imagination can dream up.  By reading the
  34. ' Learn BASIC Now book, you'll learn the techniques that will enable you
  35. ' to fully customize this game and to create games of your own.
  36. '
  37. ' If the game won't run after you have changed it, you can exit without
  38. ' saving your changes by pressing Alt, F, X and choosing NO.
  39. '
  40. ' If you do want to save your changes, press Alt, F, A and enter a filename
  41. ' for saving your version of the program.  Before you save your changes,
  42. ' however, you should make sure they work by running the program and
  43. ' verifying that your changes produce the desired results.  Also, always
  44. ' be sure to keep a backup of the original program.
  45. '
  46. DEFINT A-Z
  47.  
  48. ' Here are the BASIC CONST statements you can change.  The comments tell
  49. ' you the range that each CONST value can be changed, or any limitations.
  50. CONST WELLWIDTH = 10        ' Width of playing field (well).   Range 5 to 13.
  51. CONST WELLHEIGHT = 21       ' Height of playing field.  Range 4 to 21.
  52. CONST NUMSTYLES = 7         ' Number of unique shapes.  Range 1 to 20.  Make sure you read the notes above the DATA statements at the end of the main program before you change this number!
  53. CONST WINGAME = 1000000     ' Points required to win the game.  Range 200 to 9000000.
  54. CONST NEXTLEVEL = 300       ' Helps determine when the game advances to the next level.  (Each cleared level gives player 100 points) Range 100 to 2000.
  55. CONST BASESCORE = 1000      ' Number of points needed to advance to first level.
  56. CONST ROTATEDIR = 1         ' Control rotation of blocks. Can be 1 for clockwise, or 3 for counterclockwise.
  57. ' The following sound constants are used by the PLAY command to
  58. ' produce music during the game.  To change the sounds you hear, change
  59. ' these constants.  Refer to the online help for PLAY for the correct format.
  60. ' To completely remove sound from the game set the constants equal to null.
  61. ' For example:  PLAYINTRO = ""
  62. CONST PLAYCLEARROW = "MBT255L16O4CDEGO6C"         ' Tune played when a row is cleared.  Range unlimited.
  63. CONST PLAYINTRO = "MBT170O1L8CO2CO1CDCA-A-FGFA-F" ' Song played at game start.  Range unlimited.
  64. CONST PLAYGAMEOVER = "MBT255L16O6CO4GEDC"         ' Song when the game is lost.  Range unlimited.
  65. CONST PLAYNEWBLOCK = "MBT160L28N20L24N5"          ' Song when a new block is dropped.  Range unlimited.
  66. CONST PLAYWINGAME = "T255L16O6CO4GEDCCDEFGO6CEG"  ' Song when game is won.  Range unlimited.
  67.  
  68. ' The following CONST statements should not be changed like the ones above
  69. ' because the program relies on them being this value.
  70. CONST FALSE = 0             ' 0 means FALSE.
  71. CONST TRUE = NOT FALSE      ' Anything but 0 can be thought of as TRUE.
  72. CONST SPACEBAR = 32         ' ASCII value for space character. Drops the shape.
  73. CONST DOWNARROW = 80        ' Down arrow key.  Drops the shape.
  74. CONST RIGHTARROW = 77       ' Right arrow key.  Moves the shape right.
  75. CONST UPARROW = 72          ' Up arrow key.  Rotates the shape.
  76. CONST LEFTARROW = 75        ' Left arrow key.  Moves the shape left.
  77. CONST DOWNARROW2 = 50       ' 2 key.  Drops the shape.
  78. CONST RIGHTARROW2 = 54      ' 6 key.  Moves the shape right.
  79. CONST UPARROW2 = 56         ' 8 key.  Rotates the shape.
  80. CONST LEFTARROW2 = 52       ' 4 key.  Moves the shape left.
  81. CONST UPARROW3 = 53         ' 5 key.  Rotates the shape.
  82. CONST QUIT = "Q"            ' Q key.  Quits the game.
  83. CONST PAUSE = "P"           ' P key.  Pauses the game.
  84. CONST XMATRIX = 3           ' Width of the matrix that forms each falling unit.  See the discussions in Suggested Changes #2 and #3.
  85. CONST YMATRIX = 1           ' Depth of the matrix that forms each falling unit.
  86. CONST BYTESPERBLOCK = 76    ' Number of bytes required to store one block in Screen mode 7.
  87. CONST BLOCKVOLUME = (XMATRIX + 1) * (YMATRIX + 1)   ' Number of blocks in each shape.
  88. CONST ELEMENTSPERBLOCK = BLOCKVOLUME * BYTESPERBLOCK \ 2    ' Number of INTEGER array elements needed to store an image of a shape.
  89. CONST XSIZE = 13            ' Width, in pixels, of each block.  QBlocks assumes that the entire screen is 25 blocks wide.  Since the screen is 320 pixels wide, each block is approximately 13 pixels wide.
  90. CONST YSIZE = 8             ' Height, in pixels, of each block.  Again, QBlocks assumes that screen is 25 blocks high.  At 200 pixels down, each block is exactly 8 pixels high.
  91. CONST XOFFSET = 10          ' X position, in blocks, of the well.
  92. CONST YOFFSET = 2           ' Y position, in blocks, of the well.
  93. CONST WELLX = XSIZE * XOFFSET   ' X position, in pixels, of the start of the well.
  94. CONST WELLY = YSIZE * YOFFSET   ' Y position.
  95. CONST TILTVALUE = 9999000   ' Points required for QBlocks to tilt.
  96. CONST WELLCOLOR7 = 0        ' Well color for SCREEN 7.
  97. CONST WELLCOLOR1 = 0        ' Well color for SCREEN 1.
  98. CONST BORDERCOLOR1 = 8      ' Border color for SCREEN 1.
  99. CONST BORDERCOLOR7 = 15     ' Border color for SCREEN 7.
  100.  
  101. TYPE BlockType              ' Block datatype.
  102.     X AS INTEGER            ' Horizontal location within the well.
  103.     Y AS INTEGER            ' Vertical location within the well.
  104.     Style AS INTEGER        ' Define shape (and color, indirectly).
  105.     Rotation AS INTEGER     ' 4 possible values (0 to 3).
  106. END TYPE
  107.  
  108. ' SUB and FUNCTION declarations
  109. DECLARE FUNCTION CheckFit ()
  110. DECLARE FUNCTION GameOver ()
  111. DECLARE SUB AddBlockToWell ()
  112. DECLARE SUB CheckForFullRows ()
  113. DECLARE SUB Center (M$, Row)
  114. DECLARE SUB DeleteChunk (Highest%, Lowest%)
  115. DECLARE SUB DisplayIntro ()
  116. DECLARE SUB DisplayGameTitle ()
  117. DECLARE SUB DisplayChanges ()
  118. DECLARE SUB DrawBlock (X, Y, FillColor)
  119. DECLARE SUB InitScreen ()
  120. DECLARE SUB MakeInfoBox ()
  121. DECLARE SUB NewBlock ()
  122. DECLARE SUB PerformGame ()
  123. DECLARE SUB RedrawControls ()
  124. DECLARE SUB Show (b AS BlockType)
  125. DECLARE SUB UpdateScoring ()
  126. DECLARE SUB PutBlock (b AS BlockType)
  127. DECLARE SUB DrawAllShapes ()
  128. DECLARE SUB DrawPattern (Patttern)
  129. DECLARE SUB DrawPlayingField ()
  130.  
  131. ' DIM SHARED indicates that a variable is available to all subprograms.
  132. ' Without this statement, a variable used in one subprogram cannot be
  133. ' used by another subprogram or the main program.
  134. DIM SHARED Level AS INTEGER                                         ' Difficulty level.  0 is slowest, 9 is fastest.
  135. DIM SHARED WellBlocks(WELLWIDTH, WELLHEIGHT) AS INTEGER             ' 2 dimensional array to hold the falling shapes that have stopped falling and become part of the well.
  136. DIM SHARED CurBlock AS BlockType                                    ' The falling shape.
  137. DIM SHARED BlockShape(0 TO XMATRIX, 0 TO YMATRIX, 1 TO NUMSTYLES)   ' Holds the data required to make each shape.  Values determined by the DATA statements at the end of this window.
  138. DIM SHARED PrevScore AS LONG                                        ' Holds the previous level for scoring purposes.
  139. DIM SHARED Score AS LONG                                            ' Score.
  140. DIM SHARED ScreenWidth AS INTEGER                                   ' Width o